package com.css.upms.biz.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.css.upms.api.entity.SysRoleHome;
import com.css.upms.biz.mapper.SysRoleHomeMapper;
import com.css.upms.biz.service.ISysRoleHomeService;

import java.util.List;

import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author pcy
 * @since 2019-06-11
 */
@Service
public class SysRoleHomeServiceImpl extends ServiceImpl<SysRoleHomeMapper, SysRoleHome> implements ISysRoleHomeService {

	
	/**
	 * 根据角色id重新设置角色菜单首页
	 * @param roleId
	 */
	@Override
	public void resetMenu(String roleId) {
		if(roleId != null && !"".equals(roleId)){
			List<SysRoleHome> list = this.list(new QueryWrapper<SysRoleHome>()
					.eq("ROLE_ID", roleId)
					.notInSql("MENU_ID", "select menu_id from sys_role_menu where ROLE_ID='"+roleId+"'"));
			if(list.size() > 0) {
				for(SysRoleHome homeTemp:list) {
					this.baseMapper.deleteById(homeTemp.getRoleId());
				}
			}
		}
	}

}
